package com.cqdev.washer.api.model;

import lombok.Data;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

/**
 * @author yunfei.li
 *         类描述: TODO
 *         日期： 2018/6/28
 */
@Data
public class ScriptVO {

    private Long id;

    private String script;

    private String name;

    private String description;

    private Integer sn;

    private String lastExecuteTime;

    private String lastExecuteStatus;

    private Integer executeCount;

    private Long lastElapsedTime;

    public ScriptVO(Long id, String script, String name, String description, Integer sn, Date lastExecuteTime, String lastExecuteStatus, Integer executeCount, Long lastElapsedTime) {
        this.id = id;
        this.script = script;
        this.name = name;
        this.description = description;
        this.sn = sn;
        if(lastExecuteTime!=null){
            DateFormat dateTimeFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            dateTimeFormatter.setTimeZone(TimeZone.getTimeZone("GMT+8"));
            String formatLastExecuteTime = dateTimeFormatter.format(lastExecuteTime);
            this.lastExecuteTime = formatLastExecuteTime;
        }

        this.lastExecuteStatus = lastExecuteStatus;
        this.executeCount = executeCount;
        this.lastElapsedTime = lastElapsedTime;
    }
}
